package com.ym.curd.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ym.curd.bean.Employee;
import com.ym.curd.dao.EmployeeMapper;

@Service
public class EmployeeService {

	//引入EmployeeMapper接口对象
	@Autowired
	EmployeeMapper employeeMapper;
	//编写方法用来执行获取员工
	public List<Employee> getAll(){
		return employeeMapper.selectByExampleWithDepartment(null);
	}
	//编写一个方法用来完成员工的插入
	public void insertEmp(Employee emp){
		employeeMapper.insertSelective(emp);
	}
	//编写一个方法用来员工的编号用来查询员工的信息
	public Employee getEmployeeByEmpId(Integer empId) {
		return employeeMapper.selectByPrimaryKeyWithDepartment(empId);
	}
	//编写一个方法用来修改员工的信息
		public void updateEmp(Employee emp){
			employeeMapper.updateByPrimaryKeySelective(emp);
		}
		
	//编写一个方法用来删除员工的信息
		public void deleteEmp(Integer empId){
			employeeMapper.deleteByPrimaryKey(empId);
		}
		
}
